const baseUrl = 'https://apis.map.qq.com/ws';
const key = 'LGZBZ-I2IWP-T66DP-VRL5S-VCY7T-GGFWL';
function http({url,data,method='get'}){
	return new Promise((resolve,reject)=>{
		uni.request({
			url:baseUrl+url,
			data,
			method,
			success:(res)=>{
				resolve(res.data);
			},
			fail:(err)=>{
				reject(err);
			}
		})
	})
}

export default{
	//关键词输入提示
	suggest(currentCity,keyword){
		return http({
			url:'/place/v1/suggestion',
			data:{
				region:currentCity,
				keyword,
				key:key,
				region_fix:1
			}
		})
	},
	
	//根据经纬度得出所在位置信息
	getCur_loc(location){
		return http({
			url:'/geocoder/v1/',
			data:{
				key:key,
				location
			}
		})
	}
}